package com.first.system.controller;

import com.first.common.pojo.TbLink;
import com.first.common.vo.Result;
import com.first.system.service.LinkService;
import com.first.system.vo.LinkVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: first-project
 * @description:
 * @author: 闫锦超
 * @create: 2023-05-27 14:03
 **/
@RestController
@RequestMapping("/home/link")
@Api(tags = "友情链接")
public class LinkController {
    @Autowired
    private LinkService linkService;
    @PostMapping("/getAllLink/{currentPage}/{pageSize}")
    @ApiOperation(value = "获取所有的友情链接")
    public Result getAllLink(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody LinkVo linkVo){
                return linkService.getAllLink(currentPage,pageSize,linkVo);
    }

    @PostMapping("/addLink")
    @ApiOperation(value = "添加友情链接")
    public Result addLink(@RequestBody TbLink tbLink){
            return linkService.addLink(tbLink);
    }

    @PostMapping("/changeStatus/{linkId}/{isDisable}")
    @ApiOperation(value = "修改友情链接状态")
    public Result changeStatus(@PathVariable String linkId,@PathVariable Integer isDisable){
        return linkService.changeStatus(linkId,isDisable);
    }

    @PostMapping("/deleteLink")
    @ApiOperation(value = "删除友情链接")
    public Result deleteLink(@RequestBody TbLink tbLink){
        return linkService.deleteLink(tbLink);
    }
}
